/**  
 * @Title: ActorValidator.java
 * @Package com.limit.control.admin.validate
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-8 下午04:33:46
 * @version V1.0
 */ 
package com.limit.control.admin.validate;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.limit.model.Actor;
import com.limit.model.Module;

/** 
 * <br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-8 下午04:33:46 
 * @version V1.0
 */

public class ActorValidator extends Validator {

	/* 
	 * 
	 * @param c 
	 * @see com.jfinal.validate.Validator#validate(com.jfinal.core.Controller) 
	 */
	@Override
	protected void validate(Controller c) {
		this.validateRequired("actor.name", "nameError", "角色名称不能为空");
		this.validateRequired("modules", "modulesError", "权限列表不能为空");
	}

	/* 
	 * 
	 * @param c 
	 * @see com.jfinal.validate.Validator#handleError(com.jfinal.core.Controller) 
	 */
	@Override
	protected void handleError(Controller c) {
		c.keepModel(Actor.class);
		c.setAttr("modules", Module.dao.getListByPid(0));
		c.render("actor_view.html");
	}

}
